
$(document).ready(function() 
{

    /*************************************
    *
    *             #addType
    *
    **************************************/
    $("#addtype").fancybox({
				'titlePosition'		: 'outside',
				'transitionIn'		: 'fade',
				'transitionOut'		: 'fade',
                'onClosed'	     	: function() {
	                                      $('#feedback').remove();// if there is a feedback, remove it
                                          $('#addType_txt').val("");
                                      }
                
    });// End of #addType
      
    $('#addtype').click(function() {
    
        $('#feedback').remove();
        
    });
    /*************************************
    *
    *             #addType_btn
    *
    **************************************/     
    $('#addType_btn').click(function() {
        $('#feedback').remove(); // if there is a feedback, remove it 
        var dataString = 'addType_txt='+ $('input[name="addType_txt"]').val();
        $.ajax({
            type: "POST",
            url: "lib/post_addtype.php",
            data: dataString,
            success: function(msg){                
                if( msg == 0 )
                {
                    $('#addtype-popup').append("<div id='feedback'>Ja existe</div>");
                }                
                else if(msg < 0)
                {
                    $('#addtype-popup').append("<div id='feedback'>Invalido</div>");

                }
                else 
                {
                    $('#addtype-popup').append("<div id='feedback'>Type created</div>");
                    
                    var newType_txt = $('input[name="addType_txt"]').val();
                    $('#artifactstype_combo').append( new Option(newType_txt, msg) );
                                            
                }//else
            },//success
            error: function(msg){
            
                alert(msg);
            }//error
        
        })//ajax         
          
        return false;
    }); // End of #addType_btn       
            
            
            
            
            
            
            
            
});// End of JQuery
